#!/usr/bin/env python
# -*- coding: utf-8 -*-

from weibopy.auth import OAuthHandler
from weibopy.api import API
   
def get_sina_token():    
    '''
    Function:获取token相关信息
    Input：NONE
    Output: NONE
    author: socrates
    blog:http://blog.csdn.net/dyx1024
    date:2012-04-05
    '''  
    
    #申请应用时得到的App Key及密码
    App_key = '2986998185'
    App_secret = '1b1317e53fd0a7918b65526758a01213'

    #授权
    auth_handler = OAuthHandler(App_key, App_secret)
    auth_url = auth_handler.get_authorization_url()

    print "Please open this url by your Browser:" + auth_url
    verifier = raw_input('Please input PIN code get from above url: ').strip()
    
    #得到token及密码
    auth_handler.get_access_token(verifier)

if __name__ == '__main__':
    get_sina_token()
